package cn.sz.dzy.base.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: srb
 * @description:
 * @author: DingZhenYun
 * @create: 2021-11-04 14:46
 **/
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket customerApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("customerApi")
                .apiInfo(adminApiInfo())
                .select()
                //只显示api路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/customerApi/.*")))
                .build();

    }
    @Bean
    public Docket webApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("VIID")
                .apiInfo(adminApiInfo())
                .select()
                //只显示api路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/VIID/.*")))
                .build();

    }
    private ApiInfo adminApiInfo(){

        return new ApiInfoBuilder()
                .title("GTA1400-API文档")
                .description("本文档描述了GTA1400")
                .version("1.0")
                .contact(new Contact("dzy", "http://DD.com", "2901082882@qq.com"))
                .build();
    }
}
